package com.briup.jdk8;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Optional;
import java.util.stream.Stream;

/**
 * io 流与Stream
 */
public class IOToStream {
    public static void main(String[] args) {


        try (FileReader fr=new FileReader("C:\\Users\\sxx\\IdeaProjects\\bttc-java-basic-code\\02code\\src\\背影.txt");BufferedReader br=new BufferedReader(fr)){
            Stream<String> lines = br.lines();
            Optional<String> max = lines.max((o1, o2) -> o1.length() - o2.length());
            System.out.println(max.get());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
